home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Magazine 28 Bonus / CDRomMagazine-SoftKey-ArtPassion-FrenchVersion-Win31Mac.bin / data / cngrkpl.dir / 00121_Script_DRAG PIECE HANDLERS (REUSED) < prev    next >
Text File  |  1996-05-30  |  2KB  |  78 lines

  1. -- -----------------------------------------------------------
  2. -- The following handlers are used in games where pieces have
  3. -- to be dragged to their proper locations (the shadow game
  4. -- and the golden section game).
  5.  
  6. -- -----------------------------------------------------------
  7. -- Handler updateCurrentPlacedPiece sets the global variable
  8. -- currentPlacedPiece to its value + 1.  This handler is
  9. -- called when the user successfully places a shadow onstage.
  10.  
  11. on updateCurrentPlacedPiece
  12.   global currentPlacedPiece
  13.   
  14.   set currentPlacedPiece = currentPlacedPiece + 1
  15.   
  16. end
  17.  
  18. -- ---------------------------------------------------------------
  19. -- Handler movePiece
  20.  
  21. on movePiece whichSprite
  22.   --  empty script for the clickOn to work
  23. end
  24.  
  25. -- ---------------------------------------------------------------
  26. -- Handler trackAndCheck 
  27.  
  28. on trackAndCheck ClickedSprite, checkHandler, matchHandler
  29.   global gameOver,numOutlines,totalPlaced, totalPieces
  30.   
  31.   set oldH = the locH of sprite ClickedSprite
  32.   set oldV = the locV of sprite ClickedSprite
  33.   
  34.   -- drag the piece while the mouse is down
  35.   repeat while the stillDown
  36.     SpriteFollowMouse( ClickedSprite)
  37.     updateTimer
  38.     if gameOver then exit
  39.   end repeat  
  40.   
  41.   -- the mouse is now Up, ie. the user placed the piece somewhere
  42.   -- check if the piece was placed in the right place
  43.   do checkhandler
  44.   put the result into dragResults
  45.   
  46.   if dragResults then
  47.     playNarration "Correct"
  48.     do matchHandler
  49.     set totalPlaced = totalPlaced + 1
  50.   else
  51.     playNarration "Missed"
  52.     returnIt ClickedSprite, oldH, oldV
  53.   end if
  54.   
  55.   if totalPlaced = totalPieces then success
  56.   
  57. end
  58.  
  59. -- ---------------------------------------------------------------
  60. -- Handler spriteFollowMouse 
  61.  
  62. on spriteFollowMouse whichSprite
  63.   -- move the piece with the mouse
  64.   set the locH of sprite whichSprite = the mouseH
  65.   set the locV of sprite whichSprite = the mouseV
  66.   updateStage
  67. end 
  68.  
  69. -- return the piece to it's original location
  70. on returnIt aSprite,alocH,aLocV
  71.   set the locH of sprite aSprite to aLocH
  72.   set the locV of sprite aSprite to aLocV
  73.   updatestage
  74.   
  75. end
  76.  
  77.  
  78.